home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1985 January
/
Ahoy_Magazine_85-01_1985_Double_L.d64
/
rupert #4
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
2KB
|
91 lines
0 rem << rr13-9 >>
1 rem =-=sprite controller=-=
2 rem
5 rem sprite data must already
6 rem be in memory.
9 rem
10 rem <>
11 rem <> fnsb(n) and fnrb(n)
12 rem <> are used to set/reset
13 rem <> bit n of location m
14 rem <> when used with a poke
15 rem <> as follows:
16 rem <> poke m, fnsb(n)
17 rem <> or
18 rem <> poke m, fnrb(n)
19 rem <>
20 def fnsb(n)=peek(m) or 2^n
30 def fnrb(n)=peek(m) and (255-2^n)
35 v=53248 :rem vic chip address
40 input"which sprite # (0..7)";sn
45 if sn<0 or sn>7 then 40
50 input"which memory block (192..199)";bk
55 if bk<192 or bk>199 then 50
60 gosub 500 :rem * set pointer
70 input"what x coordinate (0..511)";x
75 if x<0 or x>511 then 70
80 gosub 600 :rem * set x coord.
90 input"what y coordinate (0..255)";y
95 if y<0 or y>255 then 90
100 gosub 700 :rem * set y coord.
110 input"what color (0..15)";c
115 if c<0 or c>15 then 110
120 gosub 800 :rem * set color
130 print"press a key to turn sprite on"
140 get a$:if a$="" then 140
150 gosub 900 :rem * turn it on
160 print"press a key to turn sprite off"
170 get a$:if a$="" then 170
180 gosub 1000 :rem * turn it off
190 print"press any key"
200 get a$:if a$="" then 200
210 goto 2000 :rem * move sprite
495 rem=-=-=-=-=-=-=-=-=-=-=-=
496 rem= set sprite pointer =
497 rem=-=-=-=-=-=-=-=-=-=-=-=
500 poke 2040+sn,bk
510 return
595 rem=-=-=-=-=-=-=-=-=-=-=-=
596 rem= set x coordinate =
597 rem=-=-=-=-=-=-=-=-=-=-=-=
600 m=v+16 : x0=x
610 if x<256 then poke m,fnrb(sn):goto 630
620 x0=x-256 : poke m,fnsb(sn)
630 poke v+sn*2,x0
640 return
695 rem=-=-=-=-=-=-=-=-=-=-=-=
696 rem= set y coordinate =
697 rem=-=-=-=-=-=-=-=-=-=-=-=
700 poke v+sn*2+1,y
710 return
795 rem=-=-=-=-=-=-=-=-=-=-=-=
796 rem= set color =
797 rem=-=-=-=-=-=-=-=-=-=-=-=
800 poke v+39+sn,c
810 return
895 rem=-=-=-=-=-=-=-=-=-=-=-=
896 rem= turn sprite on =
897 rem=-=-=-=-=-=-=-=-=-=-=-=
900 m=v+21
910 poke m,fnsb(sn)
920 return
995 rem=-=-=-=-=-=-=-=-=-=-=-=
996 rem= turn sprite off =
997 rem=-=-=-=-=-=-=-=-=-=-=-=
1000 m=v+21
1010 poke m,fnrb(sn)
1020 return
1994 rem=-=-=-=-=-=-=-=-=-=-=-=
1995 rem= move sprite =
1996 rem=-=-=-=-=-=-=-=-=-=-=-=
2000 x=24:y=150:dx=4:dy=2
2010 gosub 900
2020 x=x+dx : y=y+dy
2030 if x>320 then dx=-dx
2040 if x<24 then dx=-dx
2050 if y>229 then dy=-dy
2060 if y<50 then dy=-dy
2070 gosub 600 : gosub 700
2080 goto 2020
2090 next